//
//  ZFLayerView.swift
//  map
//
//  Created by fyzq on 2024/1/26.
//

import UIKit
import RxSwift

class ZFLayerView: ZFBaseView {
    private(set) var mapLayerView : ZFMapLayerView!
    private(set) var mapSettingView : ZFMapSettingView!
    private(set) var mapToolView : ZFMapToolView!
    private var scrollView:UIScrollView!
    override init(frame: CGRect) {
        super.init(frame: frame)
        setZFLayerView()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate func setZFLayerView(){
        
        scrollView = UIScrollView()
        addSubview(scrollView)
        
        let titleLabel = UILabel()
        titleLabel.text = "图层设置"
        titleLabel.font = UIFont.boldSystemFont(ofSize: 15)
        addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(15)
            make.centerX.equalToSuperview()
        }
        let closeLabel = UILabel()
        closeLabel.font = UIFont.iconfont(size: 26)
        closeLabel.text = .icon(icon: .ic_close)
        addSubview(closeLabel)
        closeLabel.snp.makeConstraints { make in
            make.centerY.equalTo(titleLabel.snp.centerY)
            make.right.equalTo(-15)
        }
        
        scrollView.snp.makeConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom).offset(10)
            make.left.right.bottom.equalToSuperview()
            make.height.equalTo(UIDevice.height * 0.8)
        }
        backgroundColor = R.color.color_f1()
        
        
        let addBtn = UIButton(type: UIButton.ButtonType.custom)
        addBtn.setTitle("添加自定义", for: UIControl.State.normal)
        addBtn.setTitleColor(R.color.accentColor(), for: UIControl.State.normal)
        addBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 15)
        addBtn.backgroundColor = R.color.color_d5e9()
        scrollView.addSubview(addBtn)
        addBtn.addRadius(radius: 5)
        addBtn.snp.makeConstraints { make in
            make.top.equalTo(20)
            make.left.equalTo(30)
            make.right.equalTo(-30)
            make.width.equalTo(UIDevice.width - 60)
            make.height.equalTo(40)
        }
        
        
        
        
        
        let cuctomLayerTitle =  ZFContentTitleView()
        cuctomLayerTitle.titleCell.titleLabel.text = "自定义图层"
        cuctomLayerTitle.titleCell.contentLabel.text = "更多"
        cuctomLayerTitle.titleCell.contentLabel.font = UIFont.boldSystemFont(ofSize: 13)
        cuctomLayerTitle.titleCell.arrow.isHidden = false
        scrollView.addSubview(cuctomLayerTitle)
        cuctomLayerTitle.snp.makeConstraints { make in
            make.top.equalTo(addBtn.snp.bottom).offset(10)
            make.left.equalTo(15)
            make.right.equalTo(-15)
            make.width.equalTo(UIDevice.width - 30)
        }
        
        
        mapLayerView = ZFMapLayerView()
        scrollView.addSubview(mapLayerView)
        mapLayerView.snp.makeConstraints { make in
            make.top.equalTo(cuctomLayerTitle.snp.bottom).offset(5)
            make.left.right.equalTo(cuctomLayerTitle)
        }

        
        mapSettingView = ZFMapSettingView()
        scrollView.addSubview(mapSettingView)
        mapSettingView.snp.makeConstraints { make in
            make.top.equalTo(mapLayerView.snp.bottom).offset(5)
            make.left.right.equalTo(cuctomLayerTitle)
        }

        
        mapToolView = ZFMapToolView()
        scrollView.addSubview(mapToolView)
        mapToolView.snp.makeConstraints { make in
            make.top.equalTo(mapSettingView.snp.bottom).offset(5)
            make.left.right.equalTo(cuctomLayerTitle)
            make.bottom.equalToSuperview()
        }
    
        
        
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        self.jk.addCorner(conrners: [UIRectCorner.topLeft,UIRectCorner.topRight], radius: 10)
    }
}





